/*
 * Copyright the original author or authors.
 * 
 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *	  http://www.mozilla.org/MPL/MPL-1.1.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.milib.dbg.view.content {
	import com.googlecode.milib.base.MLBroadcastClass;
	import com.googlecode.milib.display.service.MLMC;
	import com.googlecode.milib.display.ui.scroller.IScroller;

	import flash.display.MovieClip;

	/**
	 * @author Marek Brun
	 */
	public class AbstractMLDBGWindowContent extends MLBroadcastClass {
		
		public const event_TitleChanged : String = 'TitleChanged';		
		//DATA: TextEvent
		public const event_Link : String = 'Link';
		
		public var mlmc:MLMC;
		protected var width:Number;
		protected var height:Number;
		protected var isEnabled:Boolean;
		protected var scroller:IScroller;
		private var name:String;		private var title:String;
		
		public function AbstractMLDBGWindowContent(mc:MovieClip, name:String) {
			mlmc=MLMC.forInstance(mc);
			this.name=name;
		}		/*abstract*/ protected function drawData():void {}		/*abstract*/ protected function doSize():void {}		/*abstract*/ protected function doIsEnabled():void {}		/*abstract*/ protected function doIsDisabled():void {}
		/*abstract*/ protected function doSetupScroller():void {}
		/*abstract*/ public function getIsScrollable():Boolean { return true; }
		
		public function get mc():MovieClip { return mlmc.mc; };		
		public function refresh():void {
			drawData();
		}
		
		public function getTitle():String {
			return title;
		}		
		public function setTitle(title:String):void {
			this.title=title;
			broadcastEvent(event_TitleChanged);
		}
		
		public function getTabName():String {
			return name;
		}
		
		public function setupScroller(scroller:IScroller):void {
			this.scroller=scroller;
		}
		
		public function setSize(width:Number, height:Number):void {
			this.width=width;
			this.height=height;
			if(isEnabled){
				doSize();
			}
		}
		
		public function setIsEnabled(enabled:Boolean):void {
			if(isEnabled==enabled){ return; }
			isEnabled=enabled;
			if(isEnabled){
				doSize();
				drawData();
				doIsEnabled();
			}else{
				doIsDisabled();
			}
		}
	}
}
